﻿using System;
using System.Data;
using System.Collections.Generic;

namespace Kenly.DBFramework.Gateway
{
    /// <summary>
    /// 
    /// </summary>
    public interface ITableGateway : IViewGateway
    {
        /// <summary>
        /// 
        /// </summary>
        bool Changed { get; }

        /// <summary>
        /// 
        /// </summary>
        List<string> ChangedPropertyNames { get; }

        /// <summary>
        /// 
        /// </summary>
        bool IsValid { get; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="returnIdentity"></param>
        /// <returns></returns>
        int AddNew(bool returnIdentity);

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        int AddNew();

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        int DeleteById();

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        int DeleteByPK();

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        int UpdateById();

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        int UpdateByPK();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="activeTime"></param>
        /// <returns></returns>
        IDbTransaction BeginTransaction(double activeTime);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="isolationLevel"></param>
        /// <returns></returns>
        IDbTransaction BeginTransaction(IsolationLevel isolationLevel);

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        IDbTransaction BeginTransaction();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="isolationLevel"></param>
        /// <param name="activeTime"></param>
        /// <returns></returns>
        IDbTransaction BeginTransaction(IsolationLevel isolationLevel, double activeTime);

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        bool Commit();

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        bool Rollback();
       
        /// <summary>
        /// 
        /// </summary>
        /// <param name="violations"></param>
        /// <returns></returns>
        bool Validate(out List<RuleViolation> violations);
    }
}
